package com.leetao.ifkiller.core;

/**
 * if killer 微型版
 *
 * @author 菅江晖
 * @date 2021/6/12 - 1:31
 */
public class TinyIfKiller {
    private boolean status;


    public TinyIfKiller() {}

    public TinyIfKiller go(boolean expression) {
        this.status = expression;
        return this;
    }

    public TinyIfKiller and(boolean expression) {
        this.status = this.status && expression;
        return this;
    }

    public TinyIfKiller run(Runnable runnable) {
        if(!this.status) {
            return this;
        }

        runnable.run();
        return this;
    }

    public static TinyIfKiller create() {
        return new TinyIfKiller();
    }

}
